import typing
import PySide2.QtCore
import PySide2.QtGui
from PySide2.QtWidgets import QMainWindow
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *

class HorizontalTabBar(QTabBar):
    def __init__(self, *args, **kwargs):
        super(HorizontalTabBar, self).__init__(*args, **kwargs)

    def paintEvent(self, event):

        painter = QStylePainter(self)
        option = QStyleOptionTab()

        # painter.begin(self)
        for index in range(self.count()):
            self.initStyleOption(option, index)
            tabRect = self.tabRect(index)
            tabRect.moveLeft(10)
            painter.drawControl(QStyle.CE_TabBarTabShape, option)
            painter.drawText(tabRect, Qt.AlignVCenter | Qt.TextDontClip, self.tabText(index))
        # painter.end()

class TabBarStyle(QProxyStyle):
    def sizeFromContents(self, type: QStyle.ContentsType, option: QStyleOption, size: QSize, widget: QWidget) -> QSize:
        size.transpose()
        size.setHeight(40)
        size.setWidth(60)
        return size